package com.ee.chat.common.bean;

/**
 * @Author Shane
 * @Date 2019/5/14 20:53
 * @Version V1.0
 **/
public class Result {
    public static final int success_code = 0;
    public static final int failure_code = 1;
    public static final int token_expiry_code = 2;
    public static final int illegality = 3;
    public static final String success_meg = "请求成功";
    public static final String failure_meg = "请求失败";
    public static final String token_expiry_msg = "token失效";
    public static final String illegality_msg = "非法请求";

    private int code;
    private String msg;
    private Object data;


    public Result() {
    }

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Result(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static Result returnSuccess(Object data){
        return new Result(success_code, success_meg, data);
    }

    public static Result returnFailure(){
        return new Result(failure_code, failure_meg, null);
    }

    public static Result returnTokenExpiry(){
        return new Result(token_expiry_code, token_expiry_msg, null);
    }

    public static Result retuenIllegality(){
        return new Result(illegality, illegality_msg, null);
    }

    public static Result returnFailure(String msg){
        return new Result(failure_code, msg, null);
    }

    public static Result returnResult(int code, String msg){
        return new Result(code, msg);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
